<template>
  <div class="layout-search-wrap">
    <div class="search-header">
      <div class="search-header-logo">
        <nuxt-link to="/"><img src="/logo.png"/></nuxt-link>
      </div>
      <div class="search-header-input">
        <input v-model="keywords" placeholder="问题、文章、推品"/><span><img @click="doSearch" src="/icons/search-pc.png"/></span>
      </div>
    </div>
    <nuxt class="layout-search-content"/>
  </div>
</template>
<script>
  export default {
    data () {
      return {
      }
    },
    components: {},
    beforeCreate: function () {
    },
    methods: {
      doSearch () {
        let keywords = this.$store.state.content_search.keywords
        if (keywords !== null && keywords !== undefined && keywords !== '') {
          this.$store.dispatch('content_search/getContentData', {
            keywords: keywords
          })
        }
      }
    },
    computed: {
      keywords: {
        get () {
          return this.$store.state.content_search.keywords
        },
        set (value) {
          this.$store.dispatch('content_search/setKeywords', {keywords: value})
        }
      }
    }
  }
</script>
<style>
  .layout-search-wrap {
    width: 100%;
  }

  .search-header, .layout-search-content {
    margin: 0 auto;
  }

  .search-header-logo {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 5px;
  }

  .search-header-input {
    margin: 0 auto;
    width: 700px;
    height: 50px;
    line-height: 50px;
    box-shadow: 0 3px 8px 0 rgba(0, 0, 0, 0.27);
  }

  .search-header-input > input {
    outline: none;
    border: none;
    width: 88%;
    height: 40px;
    background-color: transparent;
    padding-left: 2%;
    font-size: 1.25em;

  }

  .search-header-input > span {
    text-align: center;
    width: 10%;
    height: 100%;
  }

  .search-header-input > span > img {
    height: 30px;
    width: 30px;
    vertical-align: middle;
  }

  @media all and (min-width: 1200px) {
    .search-header, .layout-search-content {
      width: 1200px;
    }
  }

  @media all and (min-width: 767px) and (max-width: 1200px) {
    .search-header, .layout-search-content {
      width: 90%;
    }
  }

  @media all and (max-width: 766px) {
    .search-header, .layout-search-content {
      width: 98%;
      padding-left: 1%;
      padding-right: 1%;
    }

    .search-header-logo {
      margin-top: 2px;
    }

    .search-header-input {
      width: 300px;
    }
  }

</style>
